<template>
    <div class="wrapper">
        <HeaderView></HeaderView>
        <SiderBar></SiderBar>
        <div class="content-box" :class="{'content-collapse':collapse}" style="margin-bottom: 10px;margin-left: 130px;margin-top: 10px">

            <div class="content">
                <transition name="move" mode="out-in">
                    <keep-alive :include="tagsList">
                        <router-view></router-view>
                    </keep-alive>
                </transition>
                <Table></Table>

            </div>
        </div>
    </div>
</template>

<script>
import  Table from './Table.vue'
    import HeaderView from './Header.vue';
    import SiderBar from './SiderBar.vue'
    import Tags from './Tags.vue'
    import bus from './bus';
    export default {
        created(){
            bus.$on('collapse', msg => {
                this.collapse = msg;
            })
            // 只有在标签页列表里的页面才使用keep-alive，即关闭标签之后就不保存到内存中了。
            bus.$on('tags', msg => {
                let arr = [];
                for(let i = 0, len = msg.length; i < len; i ++){
                    msg[i].name && arr.push(msg[i].name);
                }
                this.tagsList = arr;
            })
        },
        data(){
            return {
                tagsList: [],
                collapse: false
            }
        },
        components:{
            HeaderView,
            SiderBar,
            Tags,
            Table
        },
        name: "Index"
    }
</script>

<style scoped>

</style>
